﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sparkle.MVVM.Messages
{
    public class PostMessage : IPostMessage
    {
        public string MessageName { get; set; }

        public object AttachedObject { get; set; }


        public PostMessage(string message)
        {
            MessageName = message;
        }

        public PostMessage(string message, object attachedObject)
            : this(message)
        {
            AttachedObject = attachedObject;
        }

        public void Post()
        {
            Defaults.Messages.Where(x => x.Key== MessageName)
                .ToList().ForEach(x => x.Value.Process(x.Value.AssosiatedObject,MessageName , AttachedObject));
        }
    }
}
